Both the List.Find
method and IEnumerable.FirstOrDefault
method can be used to find the first element that satisfies a
given condition in a collection. However, List.Find
can be faster than IEnumerable.FirstOrDefault
for List
objects. For small collections, the performance difference may be minor, but for large collections, it can make a noticeable difference. The same
applies for ImmutableList
and arrays too.
Applies to
What is the potential impact?
We measured at least 2x improvement in the execution time. For more details see the Benchmarks
section from the More info
tab.